﻿@model List<SnongPhoneShop.Models.DanhMucSanPham>
@{
    ViewBag.Title = "Phụ kiện";
    Layout = "~/Views/Shared/_LayoutMetroUI.cshtml";
    ViewBag.CurrPage = "Danh mục phụ kiện";  
}

@foreach (var Item in Model.Where(m => m.Publish == true).ToList()) {
    if (Item.SanPhams.FirstOrDefault(m => m.MaDanhMuc == Item.MaDanhMuc && m.Publish == true) != null) { 
        <div class="group-tiles">
            <span class="group-name"><a href="@Url.Action("DM_SanPham", "San_Pham", new { ID = Item.MaDanhMuc })">@Item.TenDanhMuc</a></span>
            <div class="column column-2">
                <div class="large-tiles tiles">
                    <div class="amazingslider-2" style="display:block;position:relative;margin:0 auto 32px;">
                        <ul class="amazingslider-slides" style="display:none;">
                            @foreach (var i in Item.SanPhams.Where(m => m.Publish == true)) { 
                                <li><img src="@i.AnhDaiDien" alt="@i.TenSanPham" /></li>
                            }
                        </ul>
                    </div>
                </div>
                <div class="medium-tiles tiles"></div>
                <div class="medium-tiles tiles"></div>
            </div>
            @{
                var DS_SP = Item.SanPhams.Where(m => m.Publish == true).Take(8).ToList();
                for (int i = 0; i < DS_SP.Count; i++)
                {
                    if (i % 3 == 0) {
                        @Html.Raw("<div class=\"column\">");
                    }
                    <div class="wide-tiles tiles">
                        <span class="title-tiles">@DS_SP[i].TenSanPham</span>
                        <img class="img-product" src="@DS_SP[i].AnhDaiDien" />
                        <div class="basic-info">
                            <ul>
                                <li>Tình trạng: @DS_SP[i].TinhTrang.TenTinhTrang</li>
                                <li>Bảo hành: @DS_SP[i].BaoHanh</li>
                                <li>Loại phụ kiện: @DS_SP[i].DanhMucSanPham.TenDanhMuc</li>
                                <li>Giá bán: @DS_SP[i].DonGia.ToString("n0") VNĐ</li>
                            </ul>
                        </div>
                        <div class="wide-tiles tiles-hover">
                            <a href="@Url.Action("CT_SanPham", "San_Pham", new { ID = DS_SP[i].MaSanPham.Trim() })"><img class="detail-view" src="/Images/ImgPage/2c_info.png" title="Xem chi tiết" /></a>
                            <a href="@Url.Action("Dat_Hang", "San_Pham", new { ID = DS_SP[i].MaSanPham.Trim() })"><img class="add-cart" src="/Images/ImgPage/Very-Basic-Plus-icon.png" title="Thêm giỏ hàng" /></a>
                        </div>
                    </div>
                    if (i % 3 == 2 || i == DS_SP.Count - 1)
                    {
                        @Html.Raw("</div>");
                    }
                }
            }           
        </div>        
    }
}
